﻿<Page
    x:Class="vsarFlightPlan.Settings"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:vsarFlightPlan"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:converters="using:vsarFlightPlan.Converters"
    mc:Ignorable="d">
    <Page.Resources>
        <converters:InvertBoolConverter x:Key="InvertBool" />
        <converters:BooltoVisibilityConverter x:Key="BooltoVisibility" />
        <converters:BooltoVisibilityConverter x:Key="InvertBooltoVisibility" InvertResult="True" />
    </Page.Resources>

    <Pivot Title="Flight Plan: Settings" Background="{StaticResource Background}">
        <Pivot.TitleTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding}" Foreground="{StaticResource PrimaryColourBrush}" />
            </DataTemplate>
        </Pivot.TitleTemplate>
        <PivotItem Header="account details">
            <StackPanel>
                <TextBlock FontWeight="Normal" Text="account name" Style="{StaticResource TitleTextBlockStyle}" FontSize="18" />
                <TextBox IsTextPredictionEnabled="False" InputScope="AlphanumericFullWidth" Text="{Binding Account, Mode=TwoWay}" />
                <Button HorizontalAlignment="Stretch" Click="LaunchSignupClick">sign up for an account</Button>

                <TextBlock FontSize="14" FontWeight="Normal" Text="The following details are for your alternate authentication credentials that you need to setup online." TextWrapping="WrapWholeWords" Style="{StaticResource TitleTextBlockStyle}" Foreground="LightGray" />
                <TextBlock FontSize="18" FontWeight="Normal" Text="username" Style="{StaticResource TitleTextBlockStyle}" />
                <TextBox InputScope="AlphanumericFullWidth" Text="{Binding Username, Mode=TwoWay}" IsTextPredictionEnabled="False" />

                <TextBlock FontSize="18" FontWeight="Normal" Text="password" Style="{StaticResource TitleTextBlockStyle}" />
                <PasswordBox Password="{Binding Password, Mode=TwoWay}" />

                <CheckBox IsChecked="{Binding StorePassword, Mode=TwoWay}">Store password?</CheckBox>
            </StackPanel>
        </PivotItem>
        <PivotItem Header="data source">
            <StackPanel>
                <TextBlock FontSize="18" Text="project" FontWeight="Normal" Style="{StaticResource TitleTextBlockStyle}" />
                <Grid>
                    <ComboBox FontSize="18" IsEnabled="{Binding LoadingProjects, Converter={StaticResource InvertBool}}" ItemsSource="{Binding Projects}" SelectedItem="{Binding SelectedProject, Mode=TwoWay}">
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Title}" />
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
                    <ProgressBar IsIndeterminate="True" IsEnabled="True" Height="18" Foreground="#FF5692F9" Visibility="{Binding LoadingProjects, Converter={StaticResource BooltoVisibility}}" />
                </Grid>
                <Button HorizontalAlignment="Stretch" Command="{Binding RefreshProjects}" HorizontalContentAlignment="Left" FontWeight="Normal">
                    <TextBlock>
                        <Span FontFamily="Segoe UI Symbol"></Span> refresh project list
                    </TextBlock>
                </Button>
                <TextBlock FontSize="18" FontWeight="Normal" Text="query" Style="{StaticResource TitleTextBlockStyle}" />
                <Grid>
                    <ComboBox ItemsSource="{Binding Queries}" IsEnabled="{Binding LoadingQueries, Converter={StaticResource InvertBool}}" SelectedItem="{Binding SelectedQuery, Mode=TwoWay}">
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding DisplayName}" />
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
                    <ProgressBar IsIndeterminate="True" IsEnabled="True" Height="18" Foreground="#FF5692F9" Visibility="{Binding LoadingQueries, Converter={StaticResource BooltoVisibility}}" />
                </Grid>
                <Button HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Command="{Binding RefreshQueries}" FontWeight="Normal">
                    <TextBlock>
                        <Span FontFamily="Segoe UI Symbol"></Span> refresh query list
                    </TextBlock>
                </Button>
                <Button HorizontalAlignment="Stretch" Content="Clear local cache" Command="{Binding ClearLocalCache}" />
            </StackPanel>
        </PivotItem>
        <PivotItem Header="filters">
            <ScrollViewer HorizontalScrollMode="Disabled" ZoomMode="Disabled">
                <StackPanel>
                    <TextBlock FontWeight="Normal" Text="show the following states by default" Style="{StaticResource TitleTextBlockStyle}" />
                    <CheckBox IsChecked="{Binding ShowByDefaultIdea, Mode=TwoWay}" Content="Idea" />
                    <CheckBox IsChecked="{Binding ShowByDefaultInFlight, Mode=TwoWay}" Content="InFlight" />
                    <CheckBox IsChecked="{Binding ShowByDefaultLanded, Mode=TwoWay}" Content="Landed" />
                    <CheckBox IsChecked="{Binding ShowByDefaultCancelled, Mode=TwoWay}" Content="Cancelled" />
                    <CheckBox IsChecked="{Binding ShowByDefaultDelayed, Mode=TwoWay}" Content="Delayed" />
                    <CheckBox IsChecked="{Binding FilterLandedProjectsByCount, Mode=TwoWay}" Content="filter by count?" />
                    <TextBlock Text="total landed projects to show" Style="{StaticResource TitleTextBlockStyle}" />
                    <TextBox IsTextPredictionEnabled="False" InputScope="Number" HorizontalContentAlignment="Center" Text="{Binding TotalLandedProjectsToShow, Mode=TwoWay}" />
                    <TextBlock Text="days of landed projects to show" Style="{StaticResource TitleTextBlockStyle}" />
                    <TextBox IsTextPredictionEnabled="False" InputScope="Number" HorizontalContentAlignment="Center" Text="{Binding TotalDaysOfLandedProjectsToShow, Mode=TwoWay}" />
                </StackPanel>
            </ScrollViewer>
        </PivotItem>
    </Pivot>
</Page>